/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.io.InputStream;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;

/**
 *
 * @author Neo
 */
@ManagedBean
@RequestScoped
public class Converter {

    public static Date stringToDateJava(String s) throws ParseException {
        SimpleDateFormat sdm = new SimpleDateFormat("dd-MM-yyyy");
        Date d = sdm.parse(s);
        return d;
    }

    public static String dateJavaToString(Date d) {
        SimpleDateFormat sdm = new SimpleDateFormat("dd-MM-yyyy");
        return sdm.format(d);
    }

  

    public static List iteratorToList(Iterator it) {
        try {
            ArrayList arr = new ArrayList();
            while (it.hasNext()) {
                Object o = it.next();
                arr.add(o);
            }
            return arr;
        } catch (Exception e) {
            return null;
        }

    }
}
